<template>
  <contractLayout>
    <!-- 合同列表 -->
    <template slot="left">
      <contractList :pageInfo="contract.pager" placeholder="请输入物业名称" searchName="projectName" v-loading="contract.loading" element-loading-text="数据加载中...">
        <ul class="contractList">
          <li v-for="item in contract.tableData" :key="item.lessorContractId" :class="{active: item.active}" @click="changeAccountList(item.lessorContractId)">
            <div class="top">
              <div class="title" :title="item.propertyNames">
                {{item.propertyNames | ellipsis}}
                <img :src="NewIcon" class="imgIcon" v-if="item.status == '10'" />
              </div>
              <div class="btn">
                <span class="btn-span" @click.stop="$refs.contractView.show(item.lessorContractId)">查看合同</span>
                <span @click.stop="handleClickEditData(item)">新建应付</span>
              </div>
            </div>
            <el-row>
              <el-col :span="8">建筑面积</el-col>
              <el-col :span="16">{{item.buildingArea}}㎡</el-col>
            </el-row>
            <el-row>
              <el-col :span="8">物业地址</el-col>
              <el-col :span="16">{{item.address}}</el-col>
            </el-row>
            <el-row>
              <el-col :span="8">合同期限</el-col>
              <el-col :span="16">{{item.startDate}}至{{item.endDate}}</el-col>
            </el-row>
          </li>
        </ul>
      </contractList>
    </template>
    <div class="card-box listBox">
      <div class="card-title">应付信息</div>
      <dataList
				ref="dataList"
        class="card-dataList"
        placeholder="搜索物业名称"
        :pageInfo="pager"
        :listData="tableData"
        :selectData="selectionList"
        searchName="projectName"
        :menuList="[{test:'应付调整'},'export']"
        :filterList="filterList"
        @menu-click="handleMenuClick"
        v-scrollBar
        openSelection
        :listLayout="['menu','filter']"
      >
        <el-table :data="tableData" align="center" @selection-change="$event => (selectionList = $event)">
          <el-table-column width="60px" type="selection"></el-table-column>
          <el-table-column label="费用周期" align="center" prop="costPeriodStart" width="200">
            <template slot-scope="scope">{{scope.row.costPeriodStart}}至{{scope.row.costPeriodEnd}}</template>
          </el-table-column>
          <el-table-column label="付款项目" width="100" align="center" prop="chargeProjectName"></el-table-column>
          <el-table-column label="合同应付金额" align="center" prop="payableMoneyOld" width="100"></el-table-column>
          <el-table-column label="应付调整金额(元)" align="center" prop="adjustmentAmount" width="100"></el-table-column>
          <el-table-column label="本月应付金额(元)" align="center" prop="payableMoney" width="100"></el-table-column>
          <el-table-column label="状态" align="center" prop="payableStatus" width="100">
            <template slot-scope="scope">{{scope.row.payableStatus | dict('payable_status')}}</template>
          </el-table-column>
          <el-table-column width="150" label="操作" align="center">
            <template slot-scope="scope">
              <el-button type="text" @click="handleShowReceivableData(scope.row)">查看</el-button>
              <span class="line" v-if="scope.row.payableStatus === '10'">|</span>
              <el-button type="text" @click="handleClickSubmit(scope.row)" v-if="scope.row.payableStatus === '10'">提交</el-button>
            </template>
          </el-table-column>
        </el-table>
      </dataList>
    </div>
    <edit-data ref="editData" @resetList="resetList" @handleClose="handleClose" v-if="editDataShow" @beforeClose="handleClose"></edit-data>
    <edit-adjustment ref="editAdjustment" @resetList="resetList" @handleClose="handleClose" v-if="editDataShow" @beforeClose="handleClose"></edit-adjustment>
    <showActual ref="showActual" @resetList="getListData" v-if="showPayable" @beforeClose="handleShowClose" @handleClose="handleShowClose"></showActual>
    <contract-view ref="contractView" @resetList="getListData"></contract-view>
  </contractLayout>
</template>

<script src="./index.js">

</script>

<style scoped lang="scss">
.listBox {
  height: 100%;
  overflow: hidden;
  .v-table {
    height: calc(100% - 50px);
  }
}
.contractList {
  li {
    position: relative;
    padding: 15px 20px;
    border-top: 1px solid rgba(97, 106, 120, 0.07);
    transition: all 0.3s linear;
    cursor: pointer;
    &:after {
      content: "";
      width: 1px;
      height: 100%;
      position: absolute;
      transition: all 0.3s linear;
      right: 0;
      top: 0;
    }
    &.active {
      background-color: #e1f7ff;
      &:after {
        background-color: #1563d1;
      }
    }
    .top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 14px;
      .title {
        color: #000;
        font-weight: bold;
        max-width: calc(100% - 5em);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        .imgIcon {
          width: 28px;
          height: 26px;
          margin-left: 10px;
        }
      }
      .btn {
        cursor: pointer;
        color: #409eff;
        .btn-span {
          margin-right: 10px;
        }
      }
    }
    .el-row {
      margin-top: 10px;
      color: #888;
      .el-col {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
.card-box {
  .line {
    display: inline-block;
    padding: 0 10px;
  }
  .card-dataList {
    padding: 16px;
    height: calc(100vh - 280px) !important;
    overflow: auto;
  }
}
</style>
